const app = require("express");
const router = app.Router();
// 根据token提供指定用户菜单权限路由
router.get("/menu", (req, res) => {
  const { token } = req.query;
  if (token === "admin-token") {
    res.send({
      code: 0,
      msg: "获取菜单权限成功",
      data: [
        {
          path: "/",
          name: "首页",
          icon: "el-icon-s-home",
        },
        {
          path: "/user",
          name: "用户管理",
          icon: "el-icon-user",
          children: [
            {
              path: "/user/list",
              name: "用户列表",
            },
            {
              path: "/user/add",
              name: "添加用户",
            },
          ],
        },
        {
          path: "/role",
          name: "角色管理",
          icon: "el-icon-s-custom",
          children: [
            {
              path: "/role/list",
              name: "角色列表",
            },
            {
              path: "/role/add",
              name: "添加角色",
            },
          ],
        },
        {
          path: "/menu",
          name: "菜单管理",
          icon: "el-icon-s-tools",
          children: [
            {
              path: "/menu/list",
              name: "菜单列表",
            },
            {
              path: "/menu/add",
              name: "添加菜单",
            },
          ],
        },
        {
          path: "/permission",
          name: "权限管理",
          icon: "el-icon-s-finance",
          children: [
            {
              path: "/permission/list",
              name: "权限列表",
            },
            {
              path: "/permission/add",
              name: "添加权限",
            },
          ],
        },

        {
          path: "/log",
          name: "日志管理",
          icon: "el-icon-s-data",
          children: [
            {
              path: "/log/list",
              name: "日志列表",
            },
            {
              path: "/log/add",
              name: "添加日志",
            },
          ],
        },
      ],
    });
  } else {
    res.send({
      code: 1,
      msg: "获取菜单权限失败",
    });
  }
}), // 提供用户菜单权限路由
  (module.exports = router); // 导出这个路由
